package edu.friday_2025_04_27.controller;
import edu.friday_2025_04_27.common.result.TableDataInfo;
import edu.friday_2025_04_27.model.SysUser;
import edu.friday_2025_04_27.model.vo.SysUserVO;
import edu.friday_2025_04_27.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/system/user")
public class SysUserController {
    @Autowired
    SysUserService userService;

//    普通查询
//    @GetMapping("/list")
//    public List<SysUser> list(){
//        return userService.selectUserList();
//    }

    //分页查询
    @GetMapping("/list")
    public TableDataInfo list(SysUserVO user, Pageable pageable) {
        int pageNum = pageable.getPageNumber() - 1;
        pageNum = Math.max(pageNum,0);
        pageable = PageRequest.of(pageNum,pageable.getPageSize());
        return userService.selectUserList(user,pageable);
    }
}
